package com.example.demo.controller;

import com.example.demo.domain.Test;
import com.example.demo.services.TestService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController //这是返回接口
//@Controller 这是返回一个页面
public class TestController {
//    @RequestMapping("/hello") get post都可以
//    @RequestMapping(value = "/user/1",method = RequestMethod.GET) g
//    @RequestMapping(value = "/user/1",method = RequestMethod.DELETE) get post都可以
    @Value("${test.hello: TEST}")
    public String hello;

    @Resource
    private TestService testService;

    @GetMapping("/hello")
    public String hello(){
        return "hello world~" + hello;
    }

    @PostMapping("/hello/post")
    public String helloPost(String name){
        return "hello world~ post" + name;
    }

    @GetMapping("/test/list")
    public List<Test> list(){
        return testService.list();
    }
}
